Skip to content

Feature: Internal driver plugin system #3693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025

Conversation

unsuman
Copy link
Contributor

@unsuman unsuman commented Jul 5, 2025

This pull request introduces a flexible, built-in plugin system for internal drivers. It leverages Go's blank import mechanism and build tags to allow for the conditional inclusion of drivers like QEMU and VZ directly into the limactl binary.

Key Changes

  • Blank Import for Driver Registration: The core of this change is the use of Go's init() function and blank import (_) pattern. Each internal driver now contains a register.go file that, when imported, automatically registers the driver with the central registry on program startup. This makes adding new built-in drivers a modular process.
  • Conditional Compilation with Build Tags: The inclusion of each driver is controlled by Go build tags (e.g., !external_qemu, !external_vz). This allows for creating custom limactl builds with or without specific drivers compiled in. This functionality lays the groundwork for the next PR, which will update the Makefile to support the use of these tags.
  • Driver Interface Refactoring: The main driver.Driver interface has been further broken down into smaller, more granular interfaces such as Lifecycle, SnapshotManager, and GuestAgent. This refactoring improves code modularity and makes the requirements for implementing a new driver clearer.
  • New driverutil Package: A new pkg/driverutil/instance.go has been introduced to centralise driver creation logic. The new CreateDriverInstance() function looks up the appropriate driver in the registry and instantiates it.

GSoC Project Context

This is the 3rd of 4 PRs in the initial GSoC project submission. It is dependent on the successful merge of the first two PRs #3691 and #3692 . After the prerequisite PRs are merged, this branch will be rebased to finalise the integration and prepare it for merging.

Related Issues

@AkihiroSuda AkihiroSuda added the gsoc/2025 Google Summer of Code 2025 label Jul 7, 2025
@AkihiroSuda AkihiroSuda added this to the v2.0 (?) milestone Jul 7, 2025
@AkihiroSuda
Copy link
Member

Please rebase $PR_N$ on $PR_{N-1}$ (#3692).

e.g.,

git rebase feature/driver-registry

@unsuman unsuman force-pushed the feature/internal-driver-system branch 5 times, most recently from c157971 to bed5e1e Compare July 9, 2025 13:29
@@ -13,7 +13,7 @@ import (
"text/tabwriter"

contfs "github.com/containerd/continuity/fs"
"github.com/docker/go-units"
units "github.com/docker/go-units"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to change this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to fix the lint issue, but it wasn’t causing it anyway!

info.DriverName = "vz"
info.VsockPort = l.vSockPort
info.VirtioPort = l.virtioPort
if l.Instance != nil && l.Instance.Dir != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant check:

Suggested change
if l.Instance != nil && l.Instance.Dir != "" {
if l.Instance != nil {


func (l *LimaWslDriver) Info() driver.Info {
var info driver.Info
if l.Instance != nil && l.Instance.Dir != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be:

Suggested change
if l.Instance != nil && l.Instance.Dir != "" {
if l.Instance != nil {

@unsuman unsuman force-pushed the feature/internal-driver-system branch 2 times, most recently from a2dbce4 to deaa857 Compare July 9, 2025 14:57
AkihiroSuda
AkihiroSuda previously approved these changes Jul 11, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@unsuman unsuman dismissed AkihiroSuda’s stale review July 11, 2025 00:58

The merge-base changed after approval.

@AkihiroSuda
Copy link
Member

Seems to need rebasing

Signed-off-by: Ansuman Sahoo <[email protected]>
@AkihiroSuda AkihiroSuda merged commit c841df5 into lima-vm:master Jul 12, 2025
61 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc/2025 Google Summer of Code 2025
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Current Drivers to new Plugin System Implement Central Registry for Built-in Plugins
3 participants